<?php

namespace App\Http\Controllers\App;

use App\Http\Controllers\Controller;
use App\Services\CashService;
use App\Services\ConfigService;
use App\Services\UserCheckService;
use App\Services\UserService;
use Illuminate\Http\Request;

class CashController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(CashService $cash_service)
    {
        $list = $cash_service->getCash()['data'];
        return $this->success($list);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CashService $cash_service)
    {
        $rs = $cash_service->add();
        return $rs['status']?$this->success($rs['data'],$rs['msg']):$this->error($rs['msg']);
    }

    // 提现需要获取提现信息 认证信息|用户余额|提现费率手续费
    public function show(){
        $data = [];
        $uc_service = new UserCheckService;
        $rs = $uc_service->getUserCheck();

        if(!$rs['status']){
            return $this->error($rs['msg']);
        }
        $data['user_check'] = $rs['data'];

        $user_service = new UserService;
        $rs = $user_service->getUserInfo();
        $data['money'] = $rs->money??0.00;

        $config_service = new ConfigService;
        $cashInfo = $config_service->getFormatConfig('cash_rate');
        $data['cash_rate'] = $cashInfo;
        return $this->success($data);
    }
}
